package com.blankii.androidlibrary.fragments

import android.annotation.SuppressLint
import android.os.Build
import com.blankii.androidlibrary.base.BaseBindingFragment
import com.blankii.androidlibrary.databinding.FragmentInfoBinding
import com.blankii.androidlibrary.utils.DataTypeUtils
import com.blankii.androidlibrary.utils.HardwareInfoUtil
import com.blankii.androidlibrary.utils.VersionUtils


internal class InfoFragment :
    BaseBindingFragment<FragmentInfoBinding>(FragmentInfoBinding::inflate) {
    override fun onCreateInit() {

    }

    @SuppressLint("SetTextI18n")
    override fun onInitView() {
        binding.apply {
            /**
             * 设备屏幕信息
             */
            this.info1Tv.text =
                "以${HardwareInfoUtil.standardHeight}(h)*${HardwareInfoUtil.standardWith}(w)分辨率为基准画布\n" + "DPi公式:屏幕密度:（宽²+高²）开根号/英寸\n" + "屏幕分辨率:${
                    HardwareInfoUtil.getDisplayWidth(requireActivity())
                }*${
                    HardwareInfoUtil.getDisplayHeight(requireActivity())
                }\n" + "屏幕 尺寸:${HardwareInfoUtil.getInch(requireActivity())} 英寸\n" + "屏幕 dpi:${
                    HardwareInfoUtil.getPPi(
                        requireActivity()
                    )
                }\n" + "屏幕类型:${HardwareInfoUtil.getDpiString(requireActivity())}\n" + "画布比例(设备宽度/w+设备高度/h)开根号:${
                    DataTypeUtils.changeDoubleToPointOne(
                        HardwareInfoUtil.getCanvasRadio(
                            requireActivity()
                        )
                    )
                }\n" + "画布比例/dpi比例:${
                    DataTypeUtils.changeDoubleToPointOne(
                        HardwareInfoUtil.getCanvasRadio(
                            requireActivity()
                        ) / HardwareInfoUtil.getDpiNum(requireActivity())
                    )
                }"
            /**
             * 软件版本信息
             */
            info2Tv.text = "应用BuildType:${VersionUtils.isApkInDebug(requireActivity())}\n"+
            "AndroidSDK版本:${VersionUtils.getAndroidSDKVersion()}\n" + "Android版本:${VersionUtils.getAndroidVersion()}\n" + "当前软件VersionCode:${
                VersionUtils.getPacketVersionCode(requireContext())
            }\n" + "当前软件VersionName:${VersionUtils.getPacketVersionName(requireContext())}\n" + "当前包名:${requireActivity().packageName}"
            /**
             * 硬件信息
             */
            info3Tv.text =
                "设备制造商:${Build.MANUFACTURER}\n" + "设备品牌:${Build.BRAND}\n" + "设备型号:${Build.MODEL}\n" + "ANDROID_ID:${
                    HardwareInfoUtil.getAndroidId(
                    )
                }"

            /**
             * 权限授权信息
             */
//            requireActivity().per
            /**
             * 存储sdcard状态
             */
        }
    }
}